from rest_framework.response import Response


class CommonResponse(Response):
    def __init__(self, code=1000, messages='ok', results=None,
                 status=None, template_name=None, headers=None,
                 exception=False, content_type=None,
                 **kwargs):
        data = {
            'code': code,
            'messages': messages,
        }
        data.update(kwargs)
        if results:
            data['results'] = results
        super().__init__(data=data, status=status,
                         template_name=template_name, headers=headers,
                         exception=exception, content_type=content_type)
